N + 1
1 N + 1 1
>
API I/O radish-miyazaki
e.g.
SQL 1 稿 SQL N
const users = await getUsers()
for (const user of users) {
const posts = await getPostsByUserId(user.id)
// ...
}
JOIN
N 1
const users = await getUsers()
const userIds = users.map((user) => user.id)
const posts = await getPostsByUserIds(userIds)